﻿using LYL.Common.RT;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WeixinSB.Model
{


    public class HongBaoModel : BaseModel
    {
        private string headImg = "/Assets/Logo.scale-240.png";

        public string HeadImg
        {
            get { return headImg; }
            set { SetProperty(ref headImg, value); }
        }

        private string nickName = "甘";

        public string NickName
        {
            get { return nickName; }
            set { SetProperty(ref nickName, value); }
        }

        private string money;

        public string Money
        {
            get { return money; }
            set { SetProperty(ref money, value); }
        }


        private List<Person> personList;

        public List<Person> PersonList
        {
            get
            {
                return personList;
            }
            set { SetProperty(ref personList, value); }
        }
    }

    public class Person : BaseNotify
    {

        private bool isChecked = true;

        public bool IsChecked
        {
            get { return isChecked; }
            set { SetProperty(ref isChecked, value); }
        }

        /// <summary>
        /// 名字
        /// </summary>
        private string name;

        public string Name
        {
            get { return name; }
            set { SetProperty(ref name, value); }
        }

        /// <summary>
        /// 是否拼手气红包
        /// </summary>
        private bool isPin;

        public bool IsPin
        {
            get { return isPin; }
            set { SetProperty(ref isPin, value); }
        }

        private DateTime date;

        public DateTime Date
        {
            get { return date; }
            set { SetProperty(ref date, value); }
        }

        private string money;

        public string Money
        {
            get { return money; }
            set { SetProperty(ref money, value); }
        }


        /// <summary>
        /// 附加信息（已领完1/1个）
        /// </summary>
        private string info;

        public string Info
        {
            get { return info; }
            set { SetProperty(ref info, value); }
        }
    }

    /// <summary>
    /// 收到红包
    /// </summary>
    public class HongBaoReceiveModel : HongBaoModel
    {
        private static HongBaoReceiveModel model;
        public static HongBaoReceiveModel Get()
        {
            if (model == null)
            {
                var rd = new Random();
                var money = rd.Next(10000, 99999) + rd.Next(9, 99) / 100.00;
                model = new HongBaoReceiveModel()
                {
                    Money = money.ToString("0.00"),
                    LuckyCount = rd.Next(10, 99),
                    ReceiveCount = rd.Next(99, 2000),
                    PersonList = new List<Person>() 
                    {
                     new Person
                     {
                       Date=DateTime.Now,
                       IsPin=true,
                       Money="16888.88",
                       Name="梁教授",
                     },
                     new Person
                     {
                       Date=DateTime.Now,
                       IsPin=true,
                       Money="12478.5",
                       Name="Fly.秋明",
                     },
                     new Person
                     {
                       Date=DateTime.Now,
                       IsPin=true,
                       Money="0.01",
                       Name="老李",
                     }
                }
                };
            }

            return model;
        }

        /// <summary>
        /// 收到红包个数
        /// </summary>
        private int receiveCount;

        public int ReceiveCount
        {
            get { return receiveCount; }
            set { SetProperty(ref receiveCount, value); }
        }

        /// <summary>
        /// 运气最佳个数
        /// </summary>
        private int luckyCount;

        public int LuckyCount
        {
            get { return luckyCount; }
            set { SetProperty(ref luckyCount, value); }
        }
    }

    /// <summary>
    /// 发出红包
    /// </summary>
    public class HongBaoSendModel : HongBaoModel
    {
        public static List<string> HongBaoPerson { get; set; }
        public HongBaoSendModel()
        {
            HongBaoPerson = new List<string> { "拜年红包", "拼手气红包", "普通红包" };
        }

        private static HongBaoSendModel model;
        public static HongBaoSendModel Get()
        {
            if (model == null)
            {
                var rd = new Random();
                model = new HongBaoSendModel()
                {
                    PersonList = new List<Person>(),
                    SendCount = rd.Next(10, 1000),
                    Date = DateTime.Now,
                    Money = (rd.Next(100, 100000) + rd.Next(9, 99) / 100.00).ToString("0.00"),
                };

                foreach (var item in HongBaoPerson)
                {
                    model.PersonList.Add(new Person
                    {
                        Name = item,
                        Date = DateTime.Now,
                        Money = rd.Next(1, 1000).ToString(),
                        IsPin = item == "拼手气红包",
                        Info = string.Format("已领完{0}/{0}", rd.Next(4, 20))
                    });
                }
            }

            return model;
        }

        /// <summary>
        /// 发出红包个数
        /// </summary>
        private int sendCount;

        public int SendCount
        {
            get { return sendCount; }
            set { SetProperty(ref sendCount, value); }
        }
    }

}
